mod filter_white_list;
mod option_request;
mod response_with_origin;

use std::{future::Future, pin::Pin};

pub use filter_white_list::*;
pub use option_request::*;
pub use response_with_origin::*;

use axum::http::StatusCode;

type PinBoxFuture<T> = Pin<Box<dyn Future<Output = T> + Send + 'static>>;

fn pin_box_future<F, T>(f: F) -> PinBoxFuture<T>
where
    F: Future<Output = T> + Send + 'static,
{
    Box::pin(f)
}

#[derive(Debug, Clone)]
pub struct MiddleError(pub StatusCode, pub String);

impl std::fmt::Display for MiddleError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&format!("code: {}  msg: {}", self.0, self.1))
    }
}

impl std::error::Error for MiddleError {}
